*Originally coded using Stata SE 16.0
*We recommend installing outreg2 to produce tables

*Set working drive to desired filepath (e.g. C:\Documents\) 
*cd "-INSERT DESIRED FILE PATH HERE-"

use FOIA_Deidentified.dta, clear


	*** ***	MAIN MANUSCRIPT *** ***

*Main Manuscript, Table 3
*Compliance by Experimental Treatments

reg DV_Reply FOIA Donor Race
outreg2 using FOIA_Results.xls, replace label ctitle("Any Reply") dec(3)

reg DaysToReply FOIA Donor Race
outreg2 using FOIA_Results.xls, append label ctitle("Days for Initial Reply") dec(3)

reg Comply FOIA Donor Race
outreg2 using FOIA_Results.xls, append label ctitle("Compliance") dec(3)

reg Pay FOIA Donor Race
outreg2 using FOIA_Results.xls, append label ctitle("Payment Requested") dec(3)

	*** ***	APPENDIX A *** ***

*Appendix A, Table 1
*FOIA Compliance by Experimental Treatments;
*Probit and Negative Generalized Linear Regressions
	
probit DV_Reply FOIA Donor Race
outreg2 using FOIA_ResultsAlt.xls, replace label ctitle("Any Reply") dec(3)

nbreg DaysToReply FOIA Donor Race
outreg2 using FOIA_ResultsAlt.xls, append label ctitle("Days for Initial Reply") dec(3)

probit Comply FOIA Donor Race
outreg2 using FOIA_ResultsAlt.xls, append label ctitle("Compliance") dec(3)

probit Pay FOIA Donor Race
outreg2 using FOIA_ResultsAlt.xls, append label ctitle("Payment Requested") dec(3)

*Appendix A, Table 2
*FOIA Compliance by Strictnes of State FOIA Laws

reg DV_Reply FOIA_5Day FOIA_10Day
*test FOIA_5Day == FOIA_10Day
*p-value 0.0001
outreg2 using FOIA_State.xls, replace label ctitle("Any Reply") dec(3)

reg DaysToReply FOIA_5Day FOIA_10Day
*test FOIA_5Day == FOIA_10Day
*p-value 0.0001
outreg2 using FOIA_State.xls, append label ctitle("Days for Initial Reply") dec(3)

reg Comply FOIA_5Day FOIA_10Day
*test FOIA_5Day == FOIA_10Day
*p-value 0.0001
outreg2 using FOIA_State.xls, append label ctitle("Compliance") dec(3)

reg Pay FOIA_5Day FOIA_10Day
*test FOIA_5Day == FOIA_10Day
*p-value 0.0003
outreg2 using FOIA_State.xls, append label ctitle("Payment Requested") dec(3)

	*** ***	APPENDIX B *** ***

*Appendix B, Table 1 
*Two sided t-tests 

*Reply Rate by Constituent Race and Condition

*No FOIA, No Donor
ttest DV_Reply if FOIA == 0 & Donor == 0,by(Race)

*No FOIA, Donor
ttest DV_Reply if FOIA == 0 & Donor == 1,by(Race)

*FOIA, No Donor
ttest DV_Reply if FOIA == 1 & Donor == 0,by(Race)

*FOIA, Donor
ttest DV_Reply if FOIA == 1 & Donor == 1,by(Race)

*Days To Initial Reply by Constituent Race and Condition

*No FOIA, No Donor
ttest DaysToReply if FOIA == 0 & Donor == 0,by(Race)

*No FOIA, Donor
ttest DaysToReply if FOIA == 0 & Donor == 1,by(Race)

*FOIA, No Donor
ttest DaysToReply if FOIA == 1 & Donor == 0,by(Race)

*FOIA, Donor
ttest DaysToReply if FOIA == 1 & Donor == 1,by(Race)


*Compliance Rate by Constituent Race and Condition

*No FOIA, No Donor
ttest Comply if FOIA == 0 & Donor == 0,by(Race)

*No FOIA, Donor
ttest Comply if FOIA == 0 & Donor == 1,by(Race)

*FOIA, No Donor
ttest Comply if FOIA == 1 & Donor == 0,by(Race)

*FOIA, Donor
ttest Comply if FOIA == 1 & Donor == 1,by(Race)


*Request for Payment by Constituent Race and Condition

*No FOIA, No Donor
ttest Pay if FOIA == 0 & Donor == 0,by(Race)

*No FOIA, Donor
ttest Pay if FOIA == 0 & Donor == 1,by(Race)

*FOIA, No Donor
ttest Pay if FOIA == 1 & Donor == 0,by(Race)

*FOIA, Donor
ttest Pay if FOIA == 1 & Donor == 1,by(Race)

	*** ***	APPENDIX C *** ***

*Appendix C, Table 1
*Effect of Political Donor Treatment by Municipal Median Household Income
	
reg DV_Reply Donor medianincome_household2017
outreg2 using FOIA_Moderation_HIncome.xls, replace label ctitle("Any Reply") dec(3)

reg DV_Reply Donor medianincome_household2017 Donor_MedianIncome
outreg2 using FOIA_Moderation_HIncome.xls, append label ctitle("Any Reply") dec(3)

reg DV_Reply Donor medianincome_household2017 Donor_MedianIncome ///
totalpop percent_nonhispanicwhite
outreg2 using FOIA_Moderation_HIncome.xls, append label ctitle("Any Reply") dec(3)

*Appendix C, Table 2
*Moderation by Municipal Median Household Income; Probit

probit DV_Reply Donor medianincome_household2017
outreg2 using FOIA_Moderation_HIncomeAlt.xls, replace label ctitle("Any Reply") dec(3)

probit DV_Reply Donor medianincome_household2017 Donor_MedianIncome
outreg2 using FOIA_Moderation_HIncomeAlt.xls, append label ctitle("Any Reply") dec(3)

probit DV_Reply Donor medianincome_household2017 Donor_MedianIncome ///
totalpop percent_nonhispanicwhite
outreg2 using FOIA_Moderation_HIncomeAlt.xls, append label ctitle("Any Reply") dec(3)

	*GRAPHS

*Appendix C, Figure 1
*Effect of Political Donor Treatment by Municipal Median Household Income

reg DV_Reply i.Donor##c.medianincome_household2017 totalpop percent_nonhispanicwhite

margins, dydx(Donor) at(medianincome_household2017=(2(1)25))

gen pipe = "|"
gen where = -0.6

marginsplot ///
, ///
title("Effect of Political Donor Treatment" /// 
"By Municipal Median Household Income") /// 
subtitle("95% CI", size(small)) ///
xtitle("Median Household Income (10,000s, 2017 USD)") ///
xlabel(, nogrid) ///
ytitle("Predicted Difference in Reply Rates") ///
ytick(-.6(3)3) ///
ylabel(-.6 "-60 pp" -.4 "-40 pp" -.2 "-20pp" 0 "0 pp" ///
.2 "20 pp", nogrid) ///
yline(0) ///
scheme(plottigblind) ///
plotregion(fcolor(white)) ///
legend(off) ///
addplot(scatter where medianincome_household2017, ///
mlabel(pipe) ms(none) mlabel(pipe) mlabpos(0) legend(off) ) ///
note("Note: Negative values indicate fewer responses to Donors than Non-Donors." ///
"Controlling for municipal demographics.", size(small))

graph export Figure_Moderation_HouseholdIncome.png, as(png) replace

drop pipe where

*Appendix C, Figure 2
*Effect of Political Donor Treatment by Municipal Median Household Income, Probit

probit DV_Reply i.Donor##c.medianincome_household2017 totalpop percent_nonhispanicwhite

margins, dydx(Donor) at(medianincome_household2017=(2(1)25))

gen pipe = "|"
gen where = -0.6

marginsplot ///
, ///
title("Marginal Effect of Political Donor Treatment" /// 
"By Municipal Median Household Income") /// subtitle("95% CI", size(small)) ///
xtitle("Median Household Income (10,000s, 2017 USD)") ///
xlabel(, nogrid) ///
ytitle("Predicted Difference in Reply Rates") ///
ytick(-.6(3)3) ///
ylabel(-.6 "-60 pp" -.4 "-40 pp" -.2 "-20pp" 0 "0 pp" ///
.2 "20 pp", nogrid) ///
yline(0) ///
scheme(plottigblind) ///
plotregion(fcolor(white)) ///
legend(off) ///
addplot(scatter where medianincome_household2017, ///
mlabel(pipe) ms(none) mlabel(pipe) mlabpos(0) legend(off) ) ///
note("Note: Negative values indicate fewer responses to Donors than Non-Donors." ///
"Probit results. Controlling for municipal demographics.", size(small))

graph export Figure_Moderation_HouseholdIncomeAlt.png, as(png) replace

drop pipe where
